package cn.com.git.workflow.dao;

import cn.com.git.common.util.generator.GeneratorEntity;
import cn.com.git.common.util.generator.MybatisGeneratorUtils;
import cn.com.git.common.util.object.StringUtil;
import org.apache.commons.lang.ObjectUtils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 代码生成类
 * Created by zhangzhenfu
 */
public class Generator {

	// 根据命名规范，只修改此常量值即可
	private static String PACKAGE_NAME = "cn.com.git.workflow";

//	private static String JDBC_DRIVER = "com.mysql.jdbc.Driver";
//	private static String JDBC_URL = "jdbc\\:mysql\\://www.b06.com:3306/mysql?characterEncoding\\=utf8&amp;useUnicode\\=true&amp;useSSL\\=false&amp;serverTimezone\\=UTC";
//	private static String JDBC_USERNAME = "root";
//	private static String JDBC_PASSWORD = "PassWord123!";


//	private static String JDBC_DRIVER = "com.mysql.jdbc.Driver";
//	private static String JDBC_URL = "jdbc:mysql://192.168.253.27:53306/dpzx_zy?nullCatalogMeansCurrent=true";
//	private static String JDBC_USERNAME = "dpzx_dcw";
//	private static String JDBC_PASSWORD = "HeRn5SIikpUkl";

	private static String JDBC_DRIVER = "com.mysql.jdbc.Driver";
	private static String JDBC_URL = "jdbc:mysql://localhost:3306/mysql?characterEncoding=utf8&amp;useUnicode=true&amp;useSSL=false&amp;serverTimezone=UTC";
	private static String JDBC_USERNAME = "root";
	private static String JDBC_PASSWORD = "PassWord123!";


	// 需要insert后返回主键的表配置，key:表名,value:主键名
	private static Map<String, String> LAST_INSERT_ID_TABLES = new HashMap<>();
	static {

	}

	/**
	 * 自动代码生成
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		List<GeneratorEntity> entities = Arrays.asList(
//				new GeneratorEntity("work_flow",StringUtil.lineToHump(ObjectUtils.toString("work_flow")),Integer.class,false),
//				new GeneratorEntity("work_flow_group",StringUtil.lineToHump(ObjectUtils.toString("work_flow_group")),Integer.class,false)
//				new GeneratorEntity("work_flow",StringUtil.lineToHump(ObjectUtils.toString("work_flow")),Integer.class,false)
				new GeneratorEntity("work_flow_operate",StringUtil.lineToHump(ObjectUtils.toString("work_flow_operate")),Integer.class,false)
		);
		MybatisGeneratorUtils.generatorMybatis(JDBC_DRIVER, JDBC_URL, JDBC_USERNAME, JDBC_PASSWORD,PACKAGE_NAME,entities);
//		MybatisGeneratorUtils.generatorDao(PACKAGE_NAME,entities);
	}

}
